var winston = require('winston'),
path = require('path');

winston.emitErrs = true;

var logger = new winston.Logger({
    transports: [
        new winston.transports.Console({
            level: 'debug',
            handleExceptions: true,
            json: false,
            colorize: true
        }),
        new winston.transports.DailyRotateFile({
            name: 'file',
            datePattern: '.yyyy-MM-dd',
            filename: path.join(__dirname, '../logs', 'server.log'),
            colorize: true
        })
    ],
    exceptionHandlers: [
        new winston.transports.File({
            filename: path.join(__dirname, '../logs', 'exception.server.log'),
        })
    ],
    exitOnError: false
});

module.exports = logger;
module.exports.stream = {
    write: function(message, encoding) {
        logger.info(message);
    }
};